Currently, with the popularization of application of networks and electronic devices, a user may frequently switch between different networks using an electronic device, and in this way, a same application may be executed in different networks.
For example, the user runs a Digital Living Network Alliance (DLNA) shared application at home in order to share a multimedia resource on the electronic device with family members. After the user goes to an airport from home, the electronic device accesses a free wireless fidelity (WI-FI) network at the airport. If the electronic device is still running the DLNA shared application at the moment, another electronic device that is in the same WI-FI network with the user may access the multimedia resource in the DLNA shared application.
Alternatively, the user is using a sensitive application such as online banking in the electronic device, and when the user switches from a home network to a free WI-FI network in a public place, the online banking application continues to run on the free WI-FI network in the public place.
However, an access point of a free WI-FI network in a public place may be established by a hacker to steal user data. Therefore, when a network connection of the electronic device is switched to a free WI-FI network corresponding to such an AP, user data is stolen by a hacker, thereby reducing security of the user data.